package com.hibase.core.mybatis.registrar;


import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;


/**
 * @author hufeng
 * @date 2019/03/22
 */

public class MybatisPlusListener implements ApplicationListener<ContextRefreshedEvent> {

    @SuppressWarnings("unchecked")
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ev) {

        ApplicationContext applicationContext = ev.getApplicationContext();

        MybatisPlusProperties mybatisPlusProperties = applicationContext.getBean(MybatisPlusProperties.class);

        GlobalConfig globalConfig = mybatisPlusProperties.getGlobalConfig();

        globalConfig.setBanner(false);
        GlobalConfig.DbConfig dbConfig = globalConfig.getDbConfig();
        dbConfig.setLogicDeleteValue(Boolean.TRUE.toString());
        dbConfig.setLogicNotDeleteValue(Boolean.FALSE.toString());
    }

}

